#!/bin/bash

# 定义一个执行命令函数,加返回状态判断,执行错误直接退出整个脚本
# 用法说明: exec_cmd sudo apt-get install tftp-hpa
exec_cmd() {
    local cmd=$*
    echo $cmd
    $cmd
    local ret=$?
    if [ $ret -eq 0 ];then
        echo "$cmd successfully."
    else
        echo "$cmd fail ret=$ret."
        # return $ret
        exit $ret
    fi
}

exec_cmd git add .
while true
do
    read -p "please input a commit describe:" describe
    if [ -n $describe ];then
        git commit -m $describe
        break 
    else
        continue
    fi
done

exec_cmd git push origin master
